#File: rdhtml_generator.py - rdhtml content generator for the web server
#JGordon & Co

import re

def process_file(name):
    try:
        file = open(name)
        code = file.read()

    except IOError,e:
        print "Rondamon: Cannot open %s. No such file or directory" % name

    out = ""
    pos = 0
    itr= re.finditer('\<\$[^*^$]*\$\>',code)
    for match in itr:
        out = out + r'print "' + code[pos:match.start()] + r'"'
        out = out + (match.group())[2:-2]# + "\n"
        pos = match.end()
    out = out + r'print "' +  code[pos:len(code)] + r'"'

    return out



#def execute_file(name,table={}):
    #rdmcode = process_file(name)
    #html = interpret2string(rdmcode,table)
    #return html
